package com.zg.autoflow.web;

import com.zg.autoflow.req.AutoflowMainIdReq;
import com.zg.autoflow.req.DiyColumnIdReq;
import com.zg.autoflow.service.AutoflowExtendsService;
import com.zg.autoflow.service.DiyColumnService;
import com.zg.autoflow.vo.ColumnsExtendsVo;
import com.zg.autoflow.vo.DiyColumnVo;
import com.zg.common.core.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
* @author zg
*/
@RestController
@RequiredArgsConstructor
@Api(tags = {"表单字段"})
public class DiyColumnController {

	private final DiyColumnService diyColumnService;

	@ApiOperation("根据表单ID查询表单字段")
	@PostMapping("/autoFlow/extends/getColumns")
	public R<List<DiyColumnVo>> getColumns(@RequestBody @Valid DiyColumnIdReq param) {
		List<DiyColumnVo> list = diyColumnService.getColumns(param.getFormId());
		return R.success(list);
	}

	@ApiOperation("根据表单ID查询表单字段及继承关系")
	@PostMapping("/autoFlow/extends/getColumnsExtends")
	public R<List<ColumnsExtendsVo>> getColumnsExtends(@RequestBody @Valid DiyColumnIdReq param) {
		List<ColumnsExtendsVo> list = diyColumnService.getColumnsExtendsByFormId(param.getFormId());
		return R.success(list);
	}
}
